import React from 'react'
import { Menu } from 'antd';
// import {NavLink} from 'react-router-dom'
import {menuList} from '../router/index'
import {withRouter} from 'react-router-dom'
const { SubMenu } = Menu;

class Sider extends React.Component {
  handleClick = e => {
    console.log('click ', e);
    console.log(this)
    this.props.history.push({pathname:e.key,state:{a:1}})
  };
  constructor (props) {
    super(props)
  }
  render() { 
    return (
      <Menu
        onClick={this.handleClick}
        style={{ width: 256 }}
        defaultSelectedKeys={['1']}
        defaultOpenKeys={['sub1']}
        mode="inline"
      >
        {menuList.map(res=>{
          return <SubMenu key={res.key} icon={<res.icon />} title={res.title}>
            {res.child && res.child.map(item=>{return <Menu.ItemGroup key={item.key} title={item.title}>
              
              {item.child&&item.child.map(it=>{return <Menu.Item key={it.key}>{it.title}</Menu.Item>})}
            </Menu.ItemGroup>
            })}       
        </SubMenu>
        })}
      </Menu>
    );
  }
}

export default withRouter(Sider);